<?php

namespace App\Entities;

use App\Entities\CooperatorModel as Cooperator;

class CooperatorEntity extends ABaseEntity
{
    public function __construct(Cooperator $model)
    {
        $this->model = $model;
    }

    /**
     * @param string $name
     * @return CooperatorEntity
     */
    public static function findByName(string $name)
    {
        $model = Cooperator::where('name', $name)->first();
        if (is_null($model)) {
            return null;
        }
        return new CooperatorEntity($model);
    }

    public static function findLikeByName(string $name)
    {
        $entityList = [];
        $result = Cooperator::where('name', 'LIKE', '%' . $name . '%')->get();
        if ($result) {
            foreach ($result as $coModel) {
                $entityList[] = new CooperatorEntity($coModel);
            }
        }
        return $entityList;
    }

    /**
     * @param int $channelId
     * @return string
     */
    public static function getChannelNameById(int $channelId)
    {
        $entity = self::find($channelId);

        return is_null($entity) ? '' : $entity->getName();
    }

    /**
     * @return int
     */
    public function getId()
    {
        return (int)$this->model->id;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->model->name;
    }

    /**
     * @param $name string
     */
    public function setName($name)
    {
        $this->model->name = $name;
    }

    /**
     * @param int $categoryId
     */
    public function setCategoryId(int $categoryId)
    {
        $this->model->category_id = $categoryId;
    }

    /**
     * @return int
     */
    public function getCategoryId()
    {
        return (int)$this->model->category_id;
    }

    /**
     * @param string $category
     */
    public function setCategory(string $category)
    {
        $this->model->category = $category;
    }

    /**
     * @return string
     */
    public function getCategory()
    {
        return (string)$this->model->category;
    }

    /**
     * @param string $begin
     */
    public function setBegin(string $begin)
    {
        $this->model->begin = $begin;
    }

    /**
     * @return string
     */
    public function getBegin()
    {
        return (string)$this->model->begin;
    }

    /**
     * @param string $end
     */
    public function setEnd(string $end)
    {
        $this->model->end = $end;
    }

    /**
     * @return string
     */
    public function getEnd()
    {
        return (string)$this->model->end;
    }

    /**
     * @return string
     */
    public function getBusinessLicenseImg(): string
    {
        return (string)$this->model->business_license_img;
    }

    /**
     * @param string $businessLicenseImg
     */
    public function setBusinessLicenseImg(string $businessLicenseImg): void
    {
        $this->model->business_license_img = $businessLicenseImg;
    }

    /**
     * @return string
     */
    public function getIdBackView(): string
    {
        return (string)$this->model->id_back_view;
    }

    /**
     * @param string $idBackView
     */
    public function setIdBackView(string $idBackView): void
    {
        $this->model->id_back_view = $idBackView;
    }

    /**
     * @return string
     */
    public function getIdFrontView(): string
    {
        return (string)$this->model->id_front_view;
    }

    /**
     * @param string $idFrontView
     */
    public function setIdFrontView(string $idFrontView): void
    {
        $this->model->id_front_view = $idFrontView;
    }

    /**
     * @return string
     */
    public function getPhone(): string
    {
        return (string)$this->model->phone;
    }

    /**
     * @param string $phone
     */
    public function setPhone(string $phone): void
    {
        $this->model->phone = $phone;
    }

    /**
     * @return string
     */
    public function getLandlinePhone(): string
    {
        return (string)$this->model->landline_phone;
    }

    /**
     * @param string $landlinePhone
     */
    public function setLandlinePhone(string $landlinePhone): void
    {
        $this->model->landline_phone = $landlinePhone;
    }

    /**
     * @return string
     */
    public function getIntro(): string
    {
        return (string)$this->model->intro;
    }

    /**
     * @param string $intro
     */
    public function setIntro(string $intro): void
    {
        $this->model->intro = $intro;
    }

    /**
     * @return string
     */
    public function getCityIds(): string
    {
        return (string)$this->model->cityIds;
    }

    /**
     * @param string $cityIds
     */
    public function setCityIds(string $cityIds): void
    {
        $this->model->cityIds = $cityIds;
    }

    /**
     * @return string
     */
    public function getBankAccount(): string
    {
        return (string)$this->model->bank_account;
    }

    /**
     * @param string $bankAccount
     */
    public function setBankAccount(string $bankAccount): void
    {
        $this->model->bank_account = $bankAccount;
    }

    /**
     * @return string
     */
    public function getContact(): string
    {
        return (string)$this->model->contact;
    }

    /**
     * @param string $contact
     */
    public function setContact(string $contact): void
    {
        $this->model->contact = $contact;
    }

    /**
     * @return int
     */
    public function getContactId(): int
    {
        return (int)$this->model->contact_id;
    }

    /**
     * @param int $contactId
     */
    public function setContactId(int $contactId): void
    {
        $this->model->contact_id = $contactId;
    }

    /**
     * @return int
     */
    public function getStatus(): int
    {
        return (int)$this->model->status;
    }

    /**
     * @param int $status
     */
    public function setStatus(int $status): void
    {
        $this->model->status = $status;
    }

    /**
     * @return string
     */
    public function getCooperatorContact(): string
    {
        return (string)$this->model->cooperator_contact;
    }

    /**
     * @param string $cooperatorContact
     */
    public function setCooperatorContact(string $cooperatorContact): void
    {
        $this->model->cooperator_contact = $cooperatorContact;
    }
}
